<!DOCTYPE html>
<html lang="en">
<head>
<!--
See https://github.com/AnalyticalGraphicsInc/cesium-google-earth-examples/blob/master/LICENSE.md

Original Work:

Copyright 2008 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
  <title>HTML5/Gears/IP Geolocation</title>
  <script src="../../Cesium/Cesium.js"></script>
  <style>
    @import url(../../Cesium/Widgets/widgets.css);
    html, body, #cesiumContainer {
        width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden;
    }
  </style>
</head>
<body>
  <div id="cesiumContainer"></div>
  <script>
  	Cesium.BingMapsApi.defaultKey = 'AgH8JB-gA1Wo9ZbGL9oCEqfD-4YAkMnMp_XzzoGbynt_CC6l27GFWqN8SJaYm6aC';
	var viewer = new Cesium.Viewer('cesiumContainer');

    function fly(position) {
        var source = new Cesium.CustomDataSource();
        viewer.dataSources.add(source);
        var entity = source.entities.add({
            position : Cesium.Cartesian3.fromDegrees(position.coords.longitude, position.coords.latitude),
            ellipse : {
                semiMajorAxis : 100.0,
                semiMinorAxis : 100.0,
                material : new Cesium.ColorMaterialProperty(new Cesium.Color(0.2, 0.2, 1.0, 0.5))
            },
            label : {
                text: 'You are here',
                verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
                eyeOffset: new Cesium.Cartesian3(0,0,-30),
                show: false
            }
        });

        function showLabel() {
            entity.label.show = true;
        }

        viewer.camera.flyTo({
            destination : Cesium.Cartesian3.fromDegrees(position.coords.longitude, position.coords.latitude, 1005.0),
            complete: showLabel
        });
    }

    // Ask browser for location, and fly there.
    navigator.geolocation.getCurrentPosition(fly);

    // Comparable Google Earth API code:
    //
    // https://code.google.com/p/earth-api-samples/source/browse/trunk/demos/geolocation/index.html

  </script>
</body>
</html>
